
import proFetch from '../../../../hrpub/common/utils/project-fetch';
import {promptBox} from 'nc-lightapp-front';
export default class TempAction{
    constructor(comp){
        this.comp = comp
    }


    onAfterFormEvent =(props,moduled,key,value,oldValue)=>{
        const {main} = props
        let data = {
            'handitemcard' : props.form.getAllFormValue('handitemcard')
        }
        if(key === 'enablestate'){
            if(main.operation === 'edit' && value.value === '3'){
               
            } 
        }
    }

    onTableSelected =(props,moduled,record,index,status) =>{
        if(record.selected){
            props.button.setButtonDisabled({
                'delete': false
            })
        }else{
            let flag = true
            let tableData = props.editTable.getAllRows('handitemgrid')
            for(let i=0; i<tableData.length; i++){
                if(tableData[i].selected){
                    flag = false
                    break
                }
            }
            props.button.setButtonDisabled({
                'delete': flag
            })
        }
    }

    onTableonSelectedAll =(props, moduleId,status,length)=>{
        props.button.setButtonDisabled({
            'delete': !status
        })
    }


    getTableData =(pk_itemtype='',type='',pageInfo={})=>{
        const {props} = this.comp
        const {main} = props
        props.dispatch({
            type: 'main/getTableData',
            payload: {
                pk_itemtype: pk_itemtype,
                type: type,
                pageInfo: pageInfo
            }
        }).then((res)=>{
            let pageInfo = {
                pageIndex: 1,
                pageSize: 10,
                total: 0,
                totalPage: 1
            }
            if(res.data && res.data.handitemgrid){
                props.editTable.setTableData('handitemgrid',res.data.handitemgrid)
                pageInfo =  res.data.handitemgrid.pageInfo
            }else{
                props.editTable.setTableData('handitemgrid',{rows:[]})
                
            }
            props.dispatch({
                type: 'main/update',
                payload: {
                   pageInfo : pageInfo, 
                   operation : 'browse'
                }
            })
        })
    }
    

}